<?php

define('URL_CHECK_CREDENTIALS', 'http://slothsoft.de/api/oauth2/resource.php');

function redirectPostRequest($url, $fields) {
	$curl = curl_init($url);

	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_POST, count($fields));
	curl_setopt($curl, CURLOPT_POSTFIELDS, stringifyHttpFields($fields));
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

	$result = curl_exec($curl);
	curl_close($curl);
	
	return $result;
}

function stringifyHttpFields($fields) {
	$result = '';
	foreach($fields as $key=>$value) {
		$result .= $key.'='.$value.'&';
	}
	rtrim($result,'&');
	return $result;
}


?>